package router

import (
	"github.com/gin-gonic/gin"
	"wechat01/handler/service"
	"wechat01/middleware"
)

func Router() *gin.Engine {
	r := gin.Default()
	r.POST("/sms", service.SendSms)
	userApi := r.Group("/api/user").Use(middleware.AuthToken())
	{
		userApi.POST("/register", service.Register)
		userApi.POST("/login", service.Login)
		userApi.GET("/getUser", service.GetUser)
	}
	friendApi := r.Group("/api/friend").Use(middleware.AuthToken())
	{
		friendApi.POST("/addFriend", service.AddFriend)
		friendApi.POST("/friendApply", service.FriendApply)
		friendApi.GET("/searchFriend", service.SearchFriend)
		friendApi.GET("/getFriend", service.GetFriend)
	}
	chatApi := r.Group("/api/chat")
	{
		chatApi.GET("/chat", service.Chat)
		chatApi.GET("/getMessage", service.GetMessage)
	}
	momentsApi := r.Group("/api/moments").Use(middleware.AuthToken())
	{
		momentsApi.POST("/addPost", service.AddPost)
		momentsApi.GET("/getPost", service.GetPost)
		momentsApi.POST("/addLike", service.AddLike)
	}
	blackApi := r.Group("/api/black").Use(middleware.AuthToken())
	{
		blackApi.POST("/addBlack", service.AddBlack)
		blackApi.GET("/getBlack", service.GetBlack)
	}
	return r
}
